<%@page import="java.io.PrintWriter"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="java.util.Arrays"%>
<%@page import="java.util.Enumeration"%>
<%@page import="org.springframework.aop.framework.Advised"%>
<%@page import="org.springframework.aop.support.AopUtils"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@page import="org.springframework.jdbc.core.simple.*"%>

<html>
<head>
<title>Spring Framework Beans</title>
</head>
<body>
<h1>ReInit db </h1>
<%
    try {
        Enumeration<String> servletContextAttributeNames = application.getAttributeNames();
        
        while (servletContextAttributeNames.hasMoreElements()) {
            String servletContextAttributeName = servletContextAttributeNames.nextElement();
            Object servletContextAttribute = application.getAttribute(servletContextAttributeName);
            if (servletContextAttribute instanceof ApplicationContext) {
                
                ApplicationContext applicationContext = (ApplicationContext)servletContextAttribute;
                
                SimpleJdbcTemplate jdbcTemplate = (SimpleJdbcTemplate)applicationContext.getBean("org.springframework.jdbc.core.simple.SimpleJdbcTemplate#0");
                if(jdbcTemplate!=null) {
                	int updates = jdbcTemplate.update("update flux set numreservation = null, modeenvoi = null, dateack=null, dateenvoi = null", new Object[] {});
                	out.println(" reinit nb update:" + updates);
                }
            }
        }
    } catch (Exception e) {
        PrintWriter printWriter = new PrintWriter(out);
        e.printStackTrace(printWriter);
        out.println();
        printWriter.flush();
    }
%>
</body>
</html>